﻿package com.badibadi.adapter;

import java.util.ArrayList;
import java.util.List;

import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.ShareSDK;

import com.badibadi.activity.FenXiangActivity;
import com.badibadi.uniclubber.R;

import android.R.integer;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MyOtherSpaceAdapter extends BaseAdapter {
	private int img[] = { R.drawable.logo_sinaweibo,
			 R.drawable.logo_qq,
			R.drawable.logo_facebook, 
			R.drawable.logo_wechat };
	private String[] text;

	private List<Integer> list;// 记录是否绑定 0未绑定 1绑定 2过期

	Context context;

	public MyOtherSpaceAdapter(Context ct, List<Integer> list) {
		context = ct;
		this.list = list;
		text = new String[] { context.getResources().getString(R.string.sinaweibo), "qq", "Facebook", 
				context.getResources().getString(R.string.wechat2),                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

		};
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return text.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return (Object) list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		// LinearLayout l3 = new LinearLayout(context);
		// LinearLayout l4 = new LinearLayout(context);
		// LinearLayout l5 = new LinearLayout(context);
		// ImageView iv3 = new ImageView(context);
		// TextView tv3 = new TextView(context);
		// iv3.setImageResource(img[position]);
		// iv3.setPadding(20, 10, 10, 10);
		// tv3.setText(text[position]);
		// tv3.setPadding(10, 10, 10, 10);
		// l3.addView(iv3);
		// l3.addView(tv3);
		// // 设置weight
		// l4.setLayoutParams(new LinearLayout.LayoutParams(
		// LinearLayout.LayoutParams.FILL_PARENT,
		// LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f));
		// l5.setBackgroundResource(R.drawable.youjiantou_bg);
		//
		// l3.addView(l4);
		// l3.addView(l5);
		// l3.setGravity(Gravity.CENTER_VERTICAL);

		LayoutInflater inflater = LayoutInflater.from(context);

		convertView = inflater.inflate(R.layout.my_other_space_adapter, null);

		ImageView head = (ImageView) convertView.findViewById(R.id.head);
		TextView name = (TextView) convertView.findViewById(R.id.name);
		TextView is_bangding = (TextView) convertView
				.findViewById(R.id.is_bangding);

		head.setImageResource(img[position]);
		name.setText(text[position]);

		// switch(position)
		// {
		// case 0://"新浪微博", "腾讯微博", "人人网", "邮箱", "手机", "facebook",
		// // "twitter", "微信",
		//
		// break;
		// }
		if (list.get(position) == 0) {
			is_bangding.setText(context.getResources().getString(R.string.l_xb158));
		} else if (list.get(position) == 1) {
			is_bangding.setText(context.getResources().getString(R.string.l_xb159));
		} else if (list.get(position) == 2) {
			is_bangding.setText(context.getResources().getString(R.string.l_xb160));
		}

		return convertView;
	}

}
